<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of RepFacturaDetallada
 *
 * @author Bryan Cruz
 */
class RepCheques extends ReportBase {

    private $where = NULL;
    public $stud;

    function __construct() {
        $this->callbackSql = "cbSqlGenerador"; //funcion que genera sql
        $this->callbackRow = "funcRows"; //funcion para cada fila generada
        $this->paramPage = "rpt_cheques_param.php";
        $this->resultPage = "rpt_cheques_resultado.php";
        $this->rootPath = RPT_PATH + "include";
        $this->label = "Consulta de Cheques Rechazados";
        $this->subtitle = $this->label;
    }

    public function funcRows() {
        $newResult = array();
        foreach ($this->lastResult as $r) {
            $sql = "select * from cllg_factura";
            $rs = $this->query($sql);
        }
        $this->lastResult = $newResult;
    }

    /**
     * Genera el sql para el reporte
     */
    public function cbSqlGenerador() {
        $sql = "SELECT * FROM cllg_cheque ";
        $w = "";
        if (isEmpty(getParam('allFechas'))) {
            if ((!isEmpty(getParam("tipoFecha")) || getParam("tipoFecha") == 0) && !isEmpty(getParam("desde")) && !isEmpty(getParam("hasta"))) {
                $tipoFecha = getParam("tipoFecha") == 1 ? "FECHA_RECHAZO" : "FECHA_REPOSICION";
                $w.=sprintf("%s BETWEEN '%s' AND '%s'", $tipoFecha, getParam("desde"), getParam("hasta"));
            } else {
                throw new Exception("<h5 style='color:blue;'>Seleccione fechas y tipo de fecha!<h5>");
            }
        }

        $this->lastQuery = isEmpty($w) ? $sql : ("$sql WHERE $w");
        $this->where = isEmpty($w) ? NULL : $w;
    }

    public function generateSQL() {
        $this->cbSqlGenerador();
        $sqlRs = $this->db->queryToArray($this->lastQuery);
        $this->lastResult = $sqlRs;
    }

}

?>
